package com.ruoyi.common.fegin;

import feign.Contract;
import feign.Feign;
import feign.Request;
import feign.Retryer;
import feign.jackson.JacksonDecoder;
import feign.jackson.JacksonEncoder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FeignConfig {

    @Value("${portal.url}")
    private String url;

    @Bean
    public Contract useFeignAnnotations(){
        return new Contract.Default();
    }
    @Bean
    public PortalApi getFeignService(){
        return Feign.builder()
                .encoder(new JacksonEncoder())
                .decoder(new JacksonDecoder())
                .retryer(new Retryer.Default(5000,5000,3))
                .target(PortalApi.class, url);
    }
}
